//
//  ZMJLrcTool.m
//  Z-QQMusic
//
//  Created by zmj on 15/11/6.
//  Copyright © 2015年 zmj. All rights reserved.
//

#import "ZMJLrcTool.h"
#import "ZMJLrc.h"

@implementation ZMJLrcTool

+ (NSArray *)lrcArrayWithLrcName:(NSString *)lrcName {
    // 歌词文件路径
    NSString *lrcFilePath = [[NSBundle mainBundle] pathForResource:lrcName ofType:nil];
    // 将歌词文件中的内容转化成字符串
    NSString *lrcString = [NSString stringWithContentsOfFile:lrcFilePath encoding:NSUTF8StringEncoding error:nil];
    NSArray *lrcArray = [lrcString componentsSeparatedByString:@"\n"];
    NSMutableArray *array = [NSMutableArray array];
    for (NSString *lrcLine in lrcArray) {
        if ([lrcLine hasPrefix:@"[ti:"] || [lrcLine hasPrefix:@"[ar:"] || [lrcLine hasPrefix:@"[al:"] || ![lrcLine hasPrefix:@"["]) {
            continue;
        }
        // 创建歌词模型
        ZMJLrc *lrc = [ZMJLrc lrcWithLrcLine:lrcLine];
        // 装入数组
        [array addObject:lrc];
        
    }
    
    
    return array;
}
@end
